package action;

import com.opensymphony.xwork2.ActionContext;
import lombok.Data;
import org.apache.struts2.ServletActionContext;
import org.springframework.beans.factory.annotation.Autowired;
import pojo.MedicalAdvice;
import pojo.Patient;
import pojo.Registry;
import pojo.yy;
import service.RegistryService;
import util.GsonUtil;
import util.PageInfo;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;
@Data
public class RegistryAction {
    @Autowired
    private RegistryService service;
    private Registry registry;
    private yy y;
    int pageNum=1;
    int pageSize=1;
    private Integer id;
    public void queryByLike() throws Exception {

        PageInfo<Registry> registryPageInfo = service.queryByLike(y, pageNum, pageSize);
        System.out.println();
        HttpServletResponse response = ServletActionContext.getResponse();
        response.setCharacterEncoding("UTF-8");
        PrintWriter out = response.getWriter();
        out.print(
                "["+GsonUtil.toJson(registryPageInfo)+","+GsonUtil.toJson(registryPageInfo.getList())+"]"
        );
        out.close();
    }
    public String add(){
        service.addRegistry(registry);
        return "success";
    }
    public String updateStatus(){
        service.update(registry,3 );
        return "successss";
    }

}
